package com.bite.order.controller;


import com.bite.product.api.ProductApi;
import com.bite.product.model.ProductInfo;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/feign")
@RestController
@Slf4j
public class FeignController {

    @Autowired
    private ProductApi productApi;

    @RequestMapping("/simple")
    public String simple(Integer id, String uname, HttpServletResponse response) {
        response.setStatus(502);
        log.info("获取到 gateway 的参数： uname: " + uname);
        return productApi.simple(id);
    }
    @RequestMapping("/multiple")
    public String multiple(Integer id, String name) {
        return productApi.multiple(id, name);
    }
    @RequestMapping("/object")
    public String object(ProductInfo productInfo) {
        return productApi.object(productInfo);
    }
    @RequestMapping("/json")
    public String json(@RequestBody ProductInfo productInfo) {
        return productApi.json(productInfo);
    }
}
